package com.css.dzj.dzjdzqs.modules.apinventory.service.impl;

import com.css.dzj.dzjdzqs.modules.apinventory.entity.JgInventoryEntity;
import com.css.dzj.dzjdzqs.modules.apinventory.entity.QJgInventoryEntity;
import com.css.dzj.dzjdzqs.modules.apinventory.mapper.ApInventMapper;
import com.css.dzj.dzjdzqs.modules.apinventory.service.ApInventService;
import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author WT
 * @Date 2020/7/2
 */
@Service
public class ApInventServiceImpl implements ApInventService {

    @Autowired
    private JPAQueryFactory jpaQueryFactory;
    @Autowired
    private ApInventMapper apInventMapper;


    @Override
    public JgInventoryEntity findByAddress(String recordProjectAddress) {

        if(StringUtils.isEmpty(recordProjectAddress)){
            throw new RuntimeException("地址参数为空");
        }
        QJgInventoryEntity q = QJgInventoryEntity.jgInventoryEntity;
        Predicate predicate = q.isNotNull().or(q.isNull());
        return jpaQueryFactory
                .selectFrom(q)
                .where(
                        predicate
                )
                .fetchOne();

    }
}
